package com.dou.you.che.web.controller.sys;

import com.dou.you.che.comm.annotation.SysLogI;
import com.dou.you.che.comm.utils.page.PageUtils;
import com.dou.you.che.comm.utils.query.QueryParam;
import com.dou.you.che.comm.utils.response.RspData;
import com.dou.you.che.core.entity.sys.SysLog;
import com.dou.you.che.service.sys.SysLogServiceI;
import com.dou.you.che.web.controller.base.BaseAct;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * 系统日志
 * @Author 黄国刚【1058118328@qq.com】
 */
@Controller
@RequestMapping("/sys/log")
public class SysLogAct extends BaseAct {

    @Autowired
    private SysLogServiceI sysLogService;

    /**
     * 列表
     */
    @SysLogI("系统日志列表")
    @ResponseBody
    @RequestMapping("/list")
    @RequiresPermissions("sys:log:list")
    public RspData list(@RequestParam Map<String, Object> params) {
        //查询列表数据
        QueryParam query = new QueryParam(params);
        List<SysLog> sysLogList = sysLogService.queryList(query);
        int total = sysLogService.queryTotal(query);

        PageUtils pageUtil = new PageUtils(sysLogList, total, query.getLimit(), query.getPage());

        return RspData.ok().put("page", pageUtil);
    }

}
